﻿using System;
using System.Drawing;
using System.Text.RegularExpressions;

namespace Rimifier.Support
{
  public class ColorRGBA
  {

    public ColorRGBA(String gameColor)
    {
      var regex = new Regex(@"([0-9]+.[0-9]+)");
      var matches = regex.Matches(gameColor);

      Red = UtilityFunctions.GetColorValue(matches[0].Value);
      Green = UtilityFunctions.GetColorValue(matches[1].Value);
      Blue = UtilityFunctions.GetColorValue(matches[2].Value);
      Alpha = UtilityFunctions.GetColorValue(matches[3].Value);
    }

    public int Red { get; set; }
    public int Green { get; set; }
    public int Blue { get; set; }
    public int Alpha { get; set; }

    public Color GetColor()
    {
      // return Color.FromArgb(Alpha, Red, Green, Blue);
			return Color.FromArgb(23, Red, Green, Blue);
    }

    public static String GetGameColor(Color color)
    {
      // String response = String.Format("RGBA({0:f3}, {1:f3}, {2:f3}, {3:f3})", (Convert.ToDecimal(color.R) / 255), (Convert.ToDecimal(color.G) / 255), (Convert.ToDecimal(color.B) / 255), (Convert.ToDecimal(color.A) / 255));
			var response = String.Format("RGBA({0:f3}, {1:f3}, {2:f3}, {3:f3})", (Convert.ToDecimal(color.R) / 255), (Convert.ToDecimal(color.G) / 255), (Convert.ToDecimal(color.B) / 255), 23);

      return response;
    }    
  }
}
